//turret.txt - Simple script for turrets
//Cell 0,1 - Stuff done flag. If both 0, nothing. Otherwise If non-zero, this 
//turret wont attack. If the turret is itself attacked, will set the not-attack setting back to 0.

begincreaturescript;

short i,target;
short last_abil;
short att_once = 0;

body;

beginstate INIT_STATE;
	set_resistance(ME,7,100);
	
	set_level(ME,5);
	//set_name(ME,"Purification Pylon");
	set_name(ME,"Inactive Pylon");
	set_boss_level(ME,1);
	if (gf(7,7) > 0)
		erase_char(ME);
		
	last_abil = get_current_tick();

	break;

beginstate DEAD_STATE;
break;

beginstate START_STATE; 
	if ((att_once == 0) && (gf(7,15) > 0)) {
		set_attitude(ME,3);
		set_name(ME,"Anti-Rogue Pylon");
		att_once = 1;
		}
		
	if (who_shot_me() >= 0) {

		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}

		
	if (get_foe_target(ME,8,0)) {
		do_attack();
		set_state(3);
		}
	if (am_i_doing_action() == FALSE)
		end_combat_turn();
break;

beginstate 3; // attacking

	if (target_ok() == FALSE)
		set_state(START_STATE);
	if (dist_to_char(get_target()) > 8) {
		set_foe_target(ME,-1);
		set_state(START_STATE);
		}

		
	do_attack();
	turret_heal();
break;

beginstate TALKING_STATE;
	print_str("Talking: The pylon is a simple organism in a crystal shell. It can't talk.");
	if (gf(7,15) == 0)
		print_str("  It is not currently getting any power from the conduits on the floor.");
break;